<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>销售单管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layui/layuiAdmin/css/admin.css" media="all">
</head>
<style>

</style>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header"><h2><b>添加销售单</b></h2></div>
                <div class="layui-card-body" pad15>
                    <div class="layui-form" lay-filter="">
                        <div class="layui-form-item">
                            <label class="layui-form-label" style=align:"left">销售单号
                                <input style="width: 500px " type="text" name="nickname" value="John"
                                       lay-verify="nickname" autocomplete="off" placeholder="请输入采购单号"
                                       class="layui-input"></label>
                            <label style="margin-left: 700px" class="layui-form-label" id="time">销售时间
                                <input type="text" name="username" value="Doe" lay-verify="nickname" autocomplete="off"
                                       placeholder="请输采购时间"
                                       class="layui-input"
                                       style="width: 500px">
                            </label>

                        </div>
                        <div class="layui-form-item" id="er">
                            <div class="layui-input-inline">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label" style=margin-top:-40px>
                                <div class="layui-input-inline"><p style=align:"left";margin-left:1px;width:90px>
                                    药品总价格</p>
                                    <input type="text" name="nickname" value="药品总额" lay-verify="nickname"
                                           autocomplete="off" placeholder="请输入昵称" class="layui-input">
                                </div>
                            </label>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label" style=align:"left";margin-left:-12px;width:90px>邮箱
                                <div class="layui-input-inline" style="margin-left:43px">
                                    <select name="role" lay-verify="">
                                        <option value="1" selected>张三</option>
                                        <option value="2">张富清</option>
                                        <option value="3" >吴洪坤</option>
                                        <option value="4" >张凯钦</option>
                                    </select>
                                </div>
                            </label>

                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label" style=align:"left";margin-left:-5px>备注</label></div>
                        <div class="layui-input-block">
                                <textarea name="remarks" placeholder="备注" class="layui-textarea"
                                          style="margin-left:-65px;margin-top:-20px "></textarea>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="setmyinfo">添加</button>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

<script src="../../layui/layui.js">
    layui.config({
        base: '../../layui/layuiAdmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['layer', 'table', 'form'], function () {
        var $ = layui.$
            , form = layui.form
            , layer = layui.layer
            , table = layui.table;

        var active = {
            add: function () {
                layer.open({
                    type: 2
                    , title: '添加销售单'
                    , skin: 'layui-layer-molv'
                    , content: 'add.html'
                    , maxmin: true
                    , area: ['480px', '570px']
                    , btn: ['确定', '取消']
                    , yes: function (index, layero) {
                        var iframeWindow = window['layui-layer-iframe' + index]
                            , submitID = 'LAY-user-front-submit'
                            , submit = layero.find('iframe').contents().find('#' + submitID);
                        //监听提交
                        iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
                            var field = data.field; //获取提交的字段
                            console.log(field)
                            console.log(JSON.stringify(field)) // 将普通js对象转换为JSON字符串对象
                            {
                                key:value;
                                key;
                                'value'
                            } // 普通表单格式 -- js对象
                            {
                                "key";
                                value;
                                "key";
                                "value"
                            } // json格式 -- json字符串对象
                            // 提交给后端 -- ajax异步提交 -- jQuery -- 在线工具参考：https://tool.oschina.net/
                            $.ajax({
                                url: "/sys_sale/add", //请求后端接口地址
                                type: "post", //请求方式get | post
                                data: JSON.stringify(field), //提交json字符串对象参数
                                contentType: "application/json;charset=utf-8", //发送信息至服务器时内容编码类型
                                dataType: "json", //后端返回参数类型
                                success: function (res) { //请求成功后回调函数res = JSONObject.toJSONString(resultMap)
                                    if (res.code == 0) {//成功
                                        layer.msg(res.msg);//弹出提示
                                        table.reload('LAY-user-manage'); //数据刷新
                                        layer.close(index); //关闭弹层
                                    }
                                    if (res.code == -1) {//系统出问题
                                        layer.msg(res.msg, {icon: 5});//弹出提示
                                    }
                                }
                            })


                        });
                        submit.trigger('click');
                    }
                });
            }
        };

        $('.layui-btn.layuiadmin-btn-useradmin').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });


    });
</script>
</body>
</html>